function SetCookie(name, value, expires, path, domain, secure) {
var today = new Date();
today.setTime(today.getTime());
if(expires) { expires *= 2592000; }
var expires_date = new Date(today.getTime() + (expires));
document.cookie = name + "=" + escape(value)
+ (expires ? ";expires=" + expires_date.toGMTString() : "")
+ (path ? ";path=" + path : "")
+ (domain ? ";domain=" + domain : "")
+ (secure ? ";secure" : "");
}

function GetCookie(name) {
var cookies = document.cookie.split( ';' );
var cookie = '';
for(var i=0; i<cookies.length; i++) {
cookie = cookies[i].split('=');

if(cookie[0].indexOf(name) >= 0) {
return (cookie.length <= 1) ? "" : unescape(cookie[1].replace(/^s+|s+$/g, ''));
}
}
return null;
}

function Delcookie(name, path, domain) {
document.cookie = name + "="
+ (path ? ";path=" + path : "")
+ (domain ? ";domain=" + domain : "")
+ ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function checkUserLogin()
{
	if (GetCookie('ams_user_level') == null || GetCookie('ams_user_name') == null) {
		alert("User login information is lost, please log in again.");
  	top.location.href='http://' + window.location.host;
		return false;
	}
	return true;
}

function checkUserLevel(){
	if (checkUserLogin()){
		var userLevel = GetCookie('ams_user_level');
		if (userLevel > 1){
			return true;
		}
	}
	$.messager.alert("Tips", "Sorry, user privileges are insufficient.", "info");
	return false;
}